import functools
from flask import session,g
from info.models import User

def login_wraps(view):
    @functools.wraps(view)
    def fun3(*args,**kwargs):
        user_id = session.get('user_id')
        if user_id is None:
            g.user = None
        else:
            g.user = User.qury.get(user_id)

        response=view(*args,**kwargs)

        return response

    return fun3





